<template>
  <div class="icons">
    <swiper class="swiper" :options="swiperOption">
      <swiper-slide v-for="(item, k) in page" :key="k">
        <div class="icons-item" v-for="i in item" :key="i.id">
          <img :src="i.imgUrl" />
          <p>{{ i.title }}</p>
        </div>
      </swiper-slide>
      <div class="swiper-pagination" slot="pagination"></div>
    </swiper>
  </div>
</template>
<script>
export default ({
  data() {
    return {
      swiperOption: {
        pagination: {
          el: '.swiper-pagination'
        }
      },
      iconsList: [
        {
          id: '01',
          imgUrl: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/175540/24/19329/6842/60ec0b0aEf35f7384/ec560dbf9b82b90b.png!q70.jpg.dpg',
          title: '京东超市'
        }, {
          id: '02',
          imgUrl: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/178015/31/13828/6862/60ec0c04Ee2fd63ac/ccf74d805a059a44.png!q70.jpg.dpg',
          title: '数码电器'
        },
        {
          id: '03',
          imgUrl: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/41867/2/15966/7116/60ec0e0dE9f50d596/758babcb4f911bf4.png!q70.jpg.dpg',
          title: '京东服饰'
        },
        {
          id: '04',
          imgUrl: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/177902/16/13776/5658/60ec0e71E801087f2/a0d5a68bf1461e6d.png!q70.jpg.dpg',
          title: '京东生鲜'
        }, {
          id: '05',
          imgUrl: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/196472/7/12807/7127/60ec0ea3Efe11835b/37c65625d94cae75.png!q70.jpg.dpg',
          title: '京东到家'
        }, {
          id: '06',
          imgUrl: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/185733/21/13527/6648/60ec0f31E0fea3e0a/d86d463521140bb6.png!q70.jpg.dpg',
          title: '充值缴费'
        }, {
          id: '07',
          imgUrl: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/199143/10/8979/4223/614599f5E45cd5464/d15aa650a0ebe596.png!q70.jpg.dpg',
          title: '物流查询'
        }, {
          id: '08',
          imgUrl: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/186080/16/13681/8175/60ec0fcdE032af6cf/c5acd2f8454c40e1.png!q70.jpg.dpg',
          title: '领券'
        }, {
          id: '09',
          imgUrl: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/196711/35/12751/6996/60ec1000E21b5bab4/38077313cb9eac4b.png!q70.jpg.dpg',
          title: '领金贴'
        }, {
          id: '10',
          imgUrl: '//m.360buyimg.com/mobilecms/s120x120_jfs/t1/37709/6/15279/6118/60ec1046E4b5592c6/a7d6b66354efb141.png!q70.jpg.dpg',
          title: 'PLUS会员'
        }
      ]
    }
  },
  computed: {
    page() {
      const pages = []
      this.iconsList.forEach((item, index) => {
        const idx = Math.floor(index / 8)
        if (!pages[idx]) pages[idx] = []
        pages[idx].push(item)
      })
      return pages
    }
  }
})
</script>
<style lang="less" scoped>
.icons {
  width: 100%;
  overflow: hidden;
  background: #fff;
  padding: 0.1rem 0;
  .swiper-pagination {
    bottom: -8px;
  }
}
.icons-item {
  width: 25%;
  padding-bottom: 25%;
  height: 0;
  float: left;
  img {
    width: 1.1rem;
    height: 1.1rem;
    display: block;
    margin: 0 auto;
    padding-top: 0.2rem;
  }
  p {
    font-size: 0.28rem;
    text-align: center;
    color: #212121;
    margin-top: 0.1rem;
  }
}
</style>
